import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-02-27
 * Time: 12:23
 */
interface Base{
    void draw();
}
class Rect implements Base{

    @Override
    public void draw() {
        System.out.println("矩形");
    }
}

class Cycle implements Base{

    @Override
    public void draw() {
        System.out.println("圆形");
    }
}

class Tri implements Base{

    @Override
    public void draw() {
        System.out.println("三角形");
    }
}

class Dog implements Comparable<Dog>{
    public String name;
    public  int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

   // @Override
//    public boolean equals(Object o) {
//        Dog obj = (Dog) o;
//        if(this.age==obj.age&&this.name.equals(obj.name)){
//            return true;
//        }else {
//            return false;
//        }
//    }


    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public int compareTo(Dog o) {
        if (this.age > o.age){
            return 1;
        }else if (this.age < o.age){
            return -1;
        }else {
            return 0;
        }
    }
}

class NameComplate implements Comparator<Dog>{

    @Override
    public int compare(Dog o1, Dog o2) {
        return o1.name.compareTo(o2.name);
    }
}

class Cat{
    public String name;
    public int age;

    public Cat(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test {
//    public static void test(Base base){
//        base.draw();
//    }
    public static void main(String[] args) {

        Cat[] cat = new Cat[3];
        cat[1]=new Cat("mimi",10);
        System.out.println(cat[1]);

//        Dog[] dog = new Dog[3];
//        dog[1] = new Dog("bit5",10);
//        dog[0] = new Dog("bit2",20);
//        dog[2] = new Dog("bit4",30);
//        NameComplate nameComplate = new NameComplate();
//        Arrays.sort(dog,nameComplate);
//        System.out.println(Arrays.toString(dog));
        /*Rect rect = new Rect();
        rect.draw();
        Base base = new Cycle();
        base.draw();*/
//        Dog dog1 = new Dog("jio",10);
//        Dog dog2 = new Dog("jio",10);

        //boolean ret = dog1.equals(dog2);
        //System.out.println(dog1.hashCode());
        //System.out.println(dog2.hashCode());
    }
}
